package com.example.demo.controller.wxPay;

import com.example.demo.QRcode.CreatQRcode;
import com.google.zxing.WriterException;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.io.IOException;

@RestController
@RequestMapping("/QRcodes")
public class QRcodeController {
    @Resource
    private CreatQRcode creatQRcode;

    /**
     * 二维码生成
     *
     * @param url 支付url
     * @return 二维码图片
     */
    @GetMapping("/createQRCode")
    public ResponseEntity<byte[]> createQRCode(@RequestParam String url) throws IOException, WriterException {
        return creatQRcode.createQRCode(url);
    }

}
